#ifndef IPHONE
#define IMPLEMENT_API
#endif

#if defined(HX_WINDOWS) || defined(HX_MACOS) || defined(HX_LINUX)
#define NEKO_COMPATIBLE
#endif

#include <hx/CFFI.h>
#include "Utils.h"
#include <stdio.h>

using namespace iap;



static value iap_get_available_items_json () {
	
	const char* itemJSON = InAppPurchase_GetAvailableItemsJSON ();
	
	if (!itemJSON) {
		
		return alloc_null ();
		
	} else {
		
		return alloc_string (itemJSON);
		
	}
	
}
DEFINE_PRIM (iap_get_available_items_json, 0);


static value iap_get_item_details (value itemID) {
	
	const char* itemDetailsJSON = InAppPurchase_GetItemDetailsJSON (val_string (itemID));
	
	if (!itemDetailsJSON) {
		
		return alloc_null ();
		
	} else {
		
		return alloc_string (itemDetailsJSON);
		
	}
	
}
DEFINE_PRIM (iap_get_item_details, 1);


static void iap_purchase_item (value itemID, value quantity, value vendorData) {
	
	InAppPurchase_PurchaseItem (val_string (itemID), val_int (quantity), val_string (vendorData));
	
}
DEFINE_PRIM (iap_get_available_items_json, 3);


extern "C" void test_main () {
	
	// Here you could do some initialization, if needed
	
}
DEFINE_ENTRY_POINT (test_main);

extern "C" int test_register_prims () { return 0; }